/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package at.prospect.manualcreator.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author haui
 */
@Entity
@Table(name = "MANUAL")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Manual.findAll", query = "SELECT m FROM Manual m"),
    @NamedQuery(name = "Manual.findByNr", query = "SELECT m FROM Manual m WHERE m.nr = :nr"),
    @NamedQuery(name = "Manual.findByName", query = "SELECT m FROM Manual m WHERE m.name = :name"),
    @NamedQuery(name = "Manual.findByBeschreibung", query = "SELECT m FROM Manual m WHERE m.beschreibung = :beschreibung")})
public class Manual implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    @Basic(optional = false)
    @NotNull
    @Column(name = "NR")
    private Integer nr;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "NAME")
    private String name;
    @Size(max = 500)
    @Column(name = "BESCHREIBUNG")
    private String beschreibung;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "manualNr")
    private Collection<ManualManualFrageZuordnung> manualManualFrageZuordnungCollection;

    public Manual() {
    }

    public Manual(Integer nr) {
        this.nr = nr;
    }

    public Manual(Integer nr, String name) {
        this.nr = nr;
        this.name = name;
    }
    
    
    public Manual(Integer nr, String name, String beschreibung) {
        this.nr = nr;
        this.name = name;
        this.beschreibung = beschreibung;
    }    
    

    public Integer getNr() {
        return nr;
    }

    public void setNr(Integer nr) {
        this.nr = nr;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getBeschreibung() {
        return beschreibung;
    }

    public void setBeschreibung(String beschreibung) {
        this.beschreibung = beschreibung;
    }

    @XmlTransient
    public Collection<ManualManualFrageZuordnung> getManualManualFrageZuordnungCollection() {
        return manualManualFrageZuordnungCollection;
    }

    public void setManualManualFrageZuordnungCollection(Collection<ManualManualFrageZuordnung> manualManualFrageZuordnungCollection) {
        this.manualManualFrageZuordnungCollection = manualManualFrageZuordnungCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (nr != null ? nr.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Manual)) {
            return false;
        }
        Manual other = (Manual) object;
        if ((this.nr == null && other.nr != null) || (this.nr != null && !this.nr.equals(other.nr))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "at.prospect.manualcreator.Manual[ nr=" + nr + " ]";
    }
    
}
